import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:razer_one/app/main/constants/color_constants.dart';
import 'package:razer_one/app/main/view/main_btn.dart';
import 'package:razer_one/app/main/view/main_text.dart';
import 'package:razer_one/app/main/view/main_textfield.dart';
import 'package:razer_one/app/modules/me/register/register_controller.dart';

class RegisterPage extends GetView<RegisterController> {
  const RegisterPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<RegisterController>(builder: (_) {
      return Scaffold(
          backgroundColor: Colors.white,
          appBar: AppBar(
            title: const Text("注册"),
          ),
          body: GestureDetector(
            behavior: HitTestBehavior.translucent,
            onTap: () {
              FocusScope.of(context).requestFocus(FocusNode());
            },
            child: ListView(
              padding: const EdgeInsets.fromLTRB(20, 30, 20, 20),
              children: [
                const Text.rich(TextSpan(children: [
                  TextSpan(
                      text: '用户名',
                      style: TextStyle(
                        fontSize: 15,
                        color: Color(kBlueColor),
                      )),
                  TextSpan(
                      text: '  (6-16位字母.数字)',
                      style: TextStyle(fontSize: 15, color: Colors.red)),
                ])),
                sizeH(5),
                MainTextField(
                  "请输入用户名",
                  _.usernameTfController,
                  inputFormatters: [
                    FilteringTextInputFormatter.allow(
                        ////只能输入字母或数字
                        RegExp("[a-zA-Z]|[0-9]")),
                  ],
                  maxLength: 16,
                ),
                sizeH(20),
                const Text.rich(TextSpan(children: [
                  TextSpan(
                      text: '昵称',
                      style: TextStyle(
                        fontSize: 15,
                        color: Color(kBlueColor),
                      )),
                  TextSpan(
                      text: '  (2-8个汉字.字母.数字)',
                      style: TextStyle(fontSize: 15, color: Colors.red)),
                ])),
                sizeH(5),
                MainTextField(
                  "请输入昵称",
                  _.nicknameTfController,
                  inputFormatters: [
                    FilteringTextInputFormatter.allow(
                        ////只能输入汉字或者字母或数字
                        RegExp("[a-zA-Z]|[\u4e00-\u9fa5]|[0-9]")),
                  ],
                  maxLength: 8,
                ),
                sizeH(20),
                const Text.rich(TextSpan(children: [
                  TextSpan(
                      text: '登录密码',
                      style: TextStyle(
                        fontSize: 15,
                        color: Color(kBlueColor),
                      )),
                  TextSpan(
                      text: '  (6-16个字母.数字)',
                      style: TextStyle(fontSize: 15, color: Colors.red)),
                ])),
                sizeH(5),
                MainTextField(
                  "请输入登录密码",
                  _.passwordTfController,
                  isPasswod: true,
                  inputFormatters: [
                    FilteringTextInputFormatter.allow(
                        //只能输入 字母或数字
                        RegExp("[a-zA-Z]|[0-9]")),
                  ],
                  maxLength: 16,
                ),
                sizeH(10),
                MainTextField(
                  "请再输入登录密码",
                  _.passwordTfController2,
                  isPasswod: true,
                  inputFormatters: [
                    FilteringTextInputFormatter.allow(
                        //只能输入 字母或数字
                        RegExp("[a-zA-Z]|[0-9]")),
                  ],
                  maxLength: 16,
                ),
                sizeH(30),
                MainCommitBtn(
                  "注册账号",
                  handle: _.registerBtnClick,
                  btnW: double.infinity,
                )
              ],
            ),
          ));
    });
  }
}
